CMAKE_MINIMUM_REQUIRED(VERSION 2.8.7 FATAL_ERROR)

PROJECT(crnn)

FIND_PACKAGE(OpenMP)

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ${OpenMP_CXX_FLAGS} -Wall")

# Change this line if your Torch7 is installed elsewhere
SET(TORCH_ROOT "$ENV{HOME}/torch/install")

# Dependencies
SET(SEARCH_PATHS "${TORCH_ROOT}/lib")
FIND_LIBRARY(THPP_LIBRARY thpp
  PATHS ${SEARCH_PATHS})
FIND_LIBRARY(LUAT_LIBRARY luaT
  PATHS ${SEARCH_PATHS})
FIND_LIBRARY(TH_LIBRARY TH
  PATHS ${SEARCH_PATHS})
FIND_LIBRARY(THC_LIBRARY THC
  PATHS ${SEARCH_PATHS})
SET(EXT_LIBRARIES ${THPP_LIBRARY} ${LUAT_LIBRARY} ${TH_LIBRARY} ${THC_LIBRARY})
SET(EXT_INCLUDE_DIRS "${TORCH_ROOT}/include" "${TORCH_ROOT}/include/TH")

# Target
INCLUDE_DIRECTORIES(${EXT_INCLUDE_DIRS})
ADD_LIBRARY(crnn SHARED init.cpp ctc.cpp lexicon.cpp bk_tree.h)
TARGET_LINK_LIBRARIES(crnn ${EXT_LIBRARIES})
